/**
 * viewer的全局方法
 * this.$bui.viewer({list,groupLenth})
 */

// import uploader from './_viewer_comp';

import Vue from 'vue';

import viewer from './_viewer.vue';

const Viewer = Vue.extend(viewer);

let uploader =  (options) => {
    const instance = new Viewer({
        propsData: options
    });
    instance.vm = instance.$mount();
    document.body.appendChild(instance.vm.$el);
    instance.vm.$on('viewer_hidden', () => {
        //点击关闭按钮后删除vue对象及dom对象
        instance.vm.$destroy()
        document.body.removeChild(instance.vm.$el)

    })
    return instance.vm;
};

export default {
    install(Vue) {
        Object.defineProperty(Vue.prototype.$bui, 'viewer', {
            value: uploader
        });
    }
};


/*

export default {
    install(Vue){
        Object.defineProperty(Vue.prototype, '$viewer', {
            value:function(list,groupList){
                if (list && list.length>0) {
                    Vue.prototype.$eventHub.$emit('viewer', list, groupList)
                }
            }
        })
    }
}*/
